<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>form表单 上传图片</title>
</head>
<body>
	<form id="form" action="../php/upload.php" method="post" enctype="multipart/form-data">
		<input id="img" type="file" name="img">
		<input id="btn" type="button" value="上传">
	</form>
	<script type="text/javascript" src="../../js/jquery-3.3.1.js"></script>
	<script type="text/javascript" src="../../js/layer/layer.js"></script>
	<script>
		$('#btn').click(function(){
			var file = $("#img").val();
			if(!file){
				layer.msg('选择上传文件');
				return;
			}
			$('#form').submit();
		});
	</script>
</body>
</html> 